var G5_Bottle2 = Window.extend({
	parent:null,
	flow:null,
	runningAction:null,
	runningAction1:null,
	status:true,
	ctor:function (parent,flow, tag) {
		this._super(parent,flow, tag);
		this.parent=parent;
		this.flow=flow;
	},
	initSp:function (){
		this.bottle=new Button(this.rootNode,2,TAG_ITEM_BOTTLE2,"#equitment/bottle2_top.png");
		this.bottle.setPosition(cc.p(gg.c_width, gg.c_height*0.9));
		if(teach_type == TAG_LEAD){
			this.bottle_top=new Button(this.rootNode,2,TAG_ITEM_BOTTLE2_TOP,"#equitment/open3.png",this.eventMenuCallback,this);
			this.bottle_top.setPosition(cc.p(gg.c_width, gg.c_height*1.08));
		}else{
			this.bottle_top=new Button(this.rootNode,2,TAG_ITEM_BOTTLE2_TOP,"#equitment/open4.png",this.eventMenuCallback,this);
			this.bottle_top.setPosition(cc.p(gg.c_width, gg.c_height*1.08));
		}
		this.meter=new Button(this.rootNode,2,TAG_ITEM_METER3,"#equitment/meter3.png");
		this.meter.setPosition(cc.p(gg.c_width*1.008, gg.c_height*1.33));
		this.meter.setOpacity(0);
		
		this.valve=new Button(this.rootNode,2,TAG_ITEM_VALVE2,"#valve/vavel1.png");
		this.valve.setPosition(cc.p(gg.c_width*0.95,gg.c_height*1.1));
		this.valve.setVisible(false);
		
		this.valve1=new Button(this.rootNode,2,TAG_ITEM_VALVE2,"#valve1/vavel1.png");
		this.valve1.setPosition(cc.p(gg.c_width*0.95, gg.c_height*1.1));
		this.valve1.setVisible(false);
		
		this.initAction();
		this.initAction1();
	},
	initAction:function(){
		var animFrames=[];
		for(var i=1;i<5;i++){
			var str="valve/vavel"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.2)
		this.runningAction=cc.repeat(cc.animate(animation),3);
		this.runningAction.retain();
	},
	initAction1:function(){
		var animFrames=[];
		for(var i=1;i<5;i++){
			var str="valve1/vavel"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.2)
		this.runningAction1=cc.repeat(cc.animate(animation),3);
		this.runningAction1.retain();
	},
	eventMenuCallback:function(pSender){
		this.showDesc(pSender.getTag());
		if(cur_tool != TAG_BUTTON_HAND){
			// 描述
			return;
		}
		if(!this.flow.checkTag(pSender.getTag())){
			// 是否可以触发
			_.error();
			this.scene.tipLayer.updateScore(gg.score);
			return;
		} else {
			if(this.status==true){
				_.clever();
				this.scene.tipLayer.updateScore(gg.score);
			}
		}
		var action = this.flow.flow.action;
		var func=cc.callFunc(function a(){this.checkActionDone(pSender)},this);
		var func1=cc.callFunc(this.close,this);
		var func2=cc.callFunc(this.next,this);
		var fadein=cc.fadeIn(2);
		var scale=cc.scaleTo(2,1.5);
		var move=cc.moveTo(2,cc.p(gg.c_width*1.4, gg.c_height*1.3));
		var fadeout=cc.fadeOut(1);
		var scale1=cc.scaleTo(1,1);
		var move1=cc.moveTo(1,cc.p(gg.c_width*1.01, gg.c_height*1.35));
		switch(pSender.getTag()){
		case TAG_ITEM_BOTTLE2_TOP:
			if(this.status==true){
				if(action==ACTION_DO1){
					this.valve.setVisible(true);
					this.bottle_top.setVisible(false);
					this.valve.runAction(cc.sequence(this.runningAction,func,func2));
				}else if(action==ACTION_DO2){
					this.bottle_top.setVisible(false);
					this.meter.runAction(cc.sequence(cc.spawn(fadein,scale,move),cc.delayTime(2),cc.spawn(fadeout,scale1,move1),func,func1,func2));
				}else if(action==ACTION_DO3){
					this.valve1.setVisible(true);
					this.bottle_top.setVisible(false);
					this.valve1.runAction(cc.sequence(this.runningAction1,func1,func2));
				}
			}
			this.status=false;
			break;
		default:
			break;
		}
	},
	checkActionDone:function(pSender){
		var tag=pSender.getTag();
		var action=this.flow.flow.action;
		if(tag==TAG_ITEM_BOTTLE2_TOP){
			if(action==ACTION_DO1){
				this.bottle_top.setVisible(true);
				this.valve.setVisible(false);
			}else if(action==ACTION_DO2){
				this.bottle_top.setVisible(false);
			}
		}
		this.status=true;
	},
	next:function(){
		this.flow.next();
	}
});